import VueRouter from 'vue-router'
import Vue from 'vue'



import Count from "../components/Count"
import List from "../components/List"
import Games from "../components/List/Games"
import Music from "../components/List/Music"
import News from "../components/List/News"




Vue.use(VueRouter)

export default  new  VueRouter({
    routes:[
        {path:'/count',component:Count,name:"count"},
        {
            path: '/list',
            component: List,
            name: "list",
            children:[
                {
                    path:'/list/games/:id',
                    component:Games,
                    name:"games",
                },
                {
                    path:'/list/music',
                    component:Music,
                    name:"music",
                    //props配置项 是一个函数 参数是哟个$route 将返回一个route.query 供组件利用props拿到对应的query传参！
                    props:(route)=>{
                        return route.query
                    }
                },
                {
                    path:'/list/news/:id',
                    component:News,
                    name:"news",
                    //props配置项 是true就 可以开启params传参的开始
                    props: true
                },
            ]
        },
        //默认路由跳转
        // {path:'',component:List}
        //redirect路由跳转
        {path:'/',redirect:"/count"}
    ]
})